package com.hkbigdata.sybx.mapper;

import com.hkbigdata.sybx.bean.Image;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigInteger;

/**
 * @author liuanbo
 * @creat 2025-05-30-13:15
 * @see 2194550857@qq.com
 */
@Mapper
public interface ImageMapper {
    @Insert("REPLACE into image_table(user_id,image_name,image_data,content_type,create_time) " +
            "values (#{userId}, #{imageName}, #{imageData}, #{contentType}, #{createTime})")
    int insertImage(Image image);

    @Select("select image_name as imageName, image_data as imageData, content_type as contentType, create_time as createTime from image_table where user_id = #{userId}")
    Image selectByUserId(String userId);
    // 新增：修改图片的SQL方法
    @Update("UPDATE image_table " +
            "SET image_name = #{imageName}, " +
            "image_data = #{imageData}, " +
            "content_type = #{contentType}, " +
            "create_time = #{createTime} " +
            "WHERE user_id = #{userId}")
    int updateImage(Image image);
}
